import {
	getGoodsInfo
} from '@/api/goods.js'
import {
	ref,
	onMounted,
} from 'vue'
export default function(goodsId) {
	    const info = ref({});// 定义数据 
		const isCollect = ref(false);
	async function getGoodsDeatailApi() {
		try {
			let res = await getGoodsInfo({
				_id: goodsId
			})
			// console.log(res)
			
		
		res.info.spec_list = res.info.spec_list.map(v=>{
			return {
				...v,
				index:0
			}
		})
		
		// console.log(res.info.spec_list)
			info.value = res.info;
			isCollect.value = res.isCollect;
			
			
			
		} catch (err) {
			console.log(err)
		}

	}

	onMounted(() => {
		getGoodsDeatailApi()
	})

	return {
		info,
		isCollect
	}

}